#!/bin/ksh #@(#) killnotes - Clean Notes Processes (from redbook SG24-4694) # Modifications made by AIX Team - RTP echo "Starting ..." let false=1 let true=0 let Force=$false let restart=$false let delay=100 let option=0 NOTESDIR=/home/notes/notesr4 NAME=notes USER=notes while getopts ":rFt:" opt; do case $opt in r ) let restart=$true ;; F ) let Force=$true let delay=0 let option=$option+1 ;; t ) if [[ $OPTARG = +([0-9]) ]] ; then let delay=$OPTARG let option=$option+1 else print 'usage: killnotes [-r] [-F] [-t time]' print 'Error: The -t option must be supplied with a time. ' print exit fi ;; \? ) print print 'usage: killnotes [-r] [-F] [-t time]' print ' where r, recycles notes' print ' F, forces a Notes Server down (not graceful)' print ' t, delay time before a forced Notes shutdown' print print 'note: This script will attempt a graceful shutdown of Notes' print ' if the -F option is not used.' print exit ;; esac done shift $(($OPTIND -1)) for i in $* do case $i in *) print 'usage: killnotes [-r] [-F] [-t time]' print exit ;; esac done if (( $option=="2" )) ; then print 'usage: killnotes [-r] [-F | -t time]' print 'Error: The -t and -F option cannot be used together. ' print exit fi # Try to shutdown Notes if [[ ! -a /opt/lotus/bin/server ]] ; then echo "Lotus Notes Server could not be found on this host." print exit fi echo "Shutting down the Lotus Notes server application..." /opt/lotus/bin/server -q & processid=$! # Sleep until the server shuts down gracefully or the delay time is up let incr=delay/5 let i=0 while (( i < delay )) ; do sleep 5 ps |cut -f2 -d" "|grep $processid 1>/dev/null 2>/dev/null if (( $?!=0 )) ; then let i=$delay fi let i=$i+$incr done # Selects the Notes process that must be killed echo "Processes..." PROCESS=`/bin/ps -ef | /bin/awk '($8$9 ~ "'$NAME'") && \ ($1 == "'$USER'") && ($2 != "'$$'") && ($3 != "'$$'")'` # Display their names and ID echo "$PROCESS" # Kill the processes for i in `echo "$PROCESS" | /bin/awk '{print $2}` do echo Killing process $i kill -9 $i done # Display and remove the shared memory echo "Shared Memory..." MEMORY=`/bin/ipcs -m | /bin/awk ' ($3 ~ "^0xf") && ($5 == "'$USER'")'` echo "$MEMORY" for i in `echo "$MEMORY" | /bin/awk '{print $2}'` do echo Removing Shared Memory $i /bin/ipcrm -m $i done # Display and remove the semaphores echo "Semaphores..." SEMAPHORES=`/bin/ipcs -s | /bin/awk ' ($3 ~ "^0xf") && ($5 == "'$USER'")'` echo $SEMAPHORES for i in `echo "$SEMAPHORES" | /bin/awk '{print $2}'` do echo Removing Semaphore $i /bin/ipcrm -s $i done # Remove lock file rm $NOTESDIR/~notes.lck 1>/dev/null 2>/dev/null # Kill server -q if still around ps -ef | awk '/server -q/ {print $2}' | xargs kill -9 > /dev/null # Run NotesPump clean # echo Y | /opt/lotus/notespump/lnpclean # Restart Notes ?? if [[ $restart = $true ]] ; then echo /home/notes/startnotes fi